package com.gxa.service.community.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.dto.communitydto.UserListDto;
import com.gxa.dto.communitydto.UserListSearchDto;
import com.gxa.entity.community.UserList;
import com.gxa.mapper.community.UserListMapper;
import com.gxa.service.community.UserListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yjl
 * @since 2022-10-11 10:05:39
 */
@Service
public class UserListServiceImpl extends ServiceImpl<UserListMapper, UserList> implements UserListService {

    @Autowired
    private UserListMapper userListMapper;

    @Override
    public PageInfo<UserListDto> queryAll(UserListSearchDto userListSearchDto,Integer pageNum,Integer pageSize) {
        Page page = PageHelper.startPage(pageNum, pageSize);
        List<UserListDto> userListDtos = userListMapper.queryAll(userListSearchDto);
        PageInfo<UserListDto> userListDtoPageInfo = new PageInfo<>(userListDtos);
        return userListDtoPageInfo;
    }

    @Override
    public void delete(Integer id) {
        userListMapper.deleteById(id);
    }

    @Override
    public void update(UserList userList) {
//        UserList userList1 = userList.setUserPwd("123456");
//        userListMapper.updateById(userList1);
        userListMapper.updatePwd(userList.getId());
    }
}
